Compile with shared ITK/VTK to reduce wheel size #346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello - after some old packages were removed from PyPI I did a little digging to see if I could shrink the antspyx wheels. I was able to reduce the final wheel size from ~300 MB to ~51 MB. The key was configuring cmake to build shared libs for ITK (and VTK, though I don't think this mattered), which also required changing the configs for symbol visibility. I then built using
cibuildwheel
which callsauditwheel repair
to copy the resulting libs into a directory (antspyx.libs
) in the wheel and modify RPATH in any libs as necessary. Surprisingly (to me) the unzipped size is about the same or even slightly bigger (extra symbols remaining?).To run the build yourself, check out this branch and run:
(this will produce manylinux wheels for cp36, 37, 38, and 39)
There is probably a bit more optimization possible here:
strip
to remove debug symbols (my initial attempt broke the wheel, but being more selective may work)See below for test output (installed and run in the officeal python:3.7 Docker image) and a comparison of the final wheel contents.
Test output after install
Contents of wheel with shared ITK libs
Contents of wheel with static ITK libs